#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
"""

def countdown(n):
    print "Counting down!"
    while n > 0:
        yield n
        n -= 1
        
# tail a file (like tail -f)
# commonly used to monitor log files
def tail(f):
    import time
    f.seek(0, 2)
    while True:
        line = f.readline()
        if not line:
            time.sleep(0.1)
            continue
        yield line

def grep(lines, searchtext):
    for line in lines:
        if searchtext in line: yield line

###
if __name__=="__main__":
    for i in countdown(5):
        print i

    log = tail(open('__init__.py'))
    pylines = grep(log, "Python")
    
    for line in pylines:
        print line,
    
    raw_input("Press any key to continute...")